'use strict';
angular.module('clientApp')
.controller('HeaderController', function ($scope, $rootScope, $location, $cookieStore) {
	$scope.isActive = function (viewLocation) {
        return viewLocation === $location.path();
    };
    $rootScope.user = null;
    var user = $cookieStore.get('user');
    if (user) {
    	$rootScope.user = user;
    }
    
    $scope.disconnect = function() {
    	$cookieStore.remove('user');
    	$rootScope.user = null;
    	$location.path('/');
    };
});